    <div class="head"><h5 class="iList">Language</h5></div>
     <form action="<?php echo url_for('directorylanguages/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" id="valid" class="mainForm" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
     	<div class="rowElem noborder">
     	<label for="name">Name:</label>
     		<div class="formRight"><input type="text" name="language[name]" value="<?php echo $form->getObject()->getName()?>"  class="validate[required]"  id="language_name" style="width: 500px" /></div>
     		<div class="fix"></div>
     	</div>
     	
     	<div class="rowElem noborder">
     	<label for="name">Culture:</label>
     		<div class="formRight"><input type="text" name="language[culture]" value="<?php echo $form->getObject()->getName()?>"  class="validate[required]"  id="language_culture" style="width: 500px" /></div>
     		<div class="fix"></div>
     	</div>
     	<div class="rowElem noborder">
     	<label for="name">Google code:</label>
     		<div class="formRight"><input type="text" name="language[google_code]" value="<?php echo $form->getObject()->getGoogleCode()?>"  class="validate[required]"  id="language_google_code" style="width: 500px" /></div>
     		<div class="fix"></div>
     	</div>
     	
     	<div class="fix"></div>
        <input type="button" value="Save" class="greyishBtn submitForm" id="save" />
        <?php if (!$form->getObject()->isNew()){
     		?>
     		<input type="button" value="Create New" class="greyishBtn submitForm" id="create_new" />
     	<?php 
     	} ?>
        <div class="fix"></div>
     </form>
     
     
<script type="text/javascript">

$("#save").click(function (event){
    submitForm();
})


$("#create_new").click(function (event){

    $.ajax({type: 'POST', url:' <?php echo url_for('directorylanguages/index')?>', script:true, cache:false,
            success: function(data) {
            	$('#category_container_div').html(data);
             } });
             
})


$("form#valid").submit(function (event){
    event.preventDefault();
    submitForm();
})

function submitForm(){
    var str=$('form#valid').serialize();

    $.ajax({type: 'POST', url:' <?php echo url_for('directorylanguages/'.($form->getObject()->isNew() ? 'create' :'update').
    (!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : ''))?>', script:true, cache:false, data:  str, 
    beforeSend: function(){
    	if (!validate()){
			return false;
        }},
            success: function(data) {
                 $('#category_container_div').html(data);
             } });
}


function validate(){
	var valid = true;
	var error_msg = "";
	if ($("#language_name").attr("value") == ""){
		valid = false;
		error_msg = "Name required";
	}
	else if (valid && $("#language_culture").attr("value") == ""){
		valid = false;
		error_msg = "Culture required";
	}
		
	if (!valid){
		$('#msg_text').html(error_msg);
		$('#error_msg').show('fast');
	}
	return valid;			
}
		
		$('form').jqTransform({imgPath:'../images/forms'});
</script>     
